package com.h3c.nem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.h3c.nem.entity.TbCareNoInfo;
import com.h3c.nem.mapper.TbCareNoInfoMapper;
import com.h3c.nem.service.ITbCareNoInfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;

/**
 * 新员工关怀未创建信息
 *
 * @author z22968
 * @date 2022/6/10 17:24
 */
@Service
public class TbCareNoInfoServiceImpl extends ServiceImpl<TbCareNoInfoMapper, TbCareNoInfo> implements ITbCareNoInfoService {
    @Resource
    TbCareNoInfoMapper tbCareNoInfoMapper;

    @Override
    public List<TbCareNoInfo> getListByReason(TbCareNoInfo.ReasonType reasonType) {
        LambdaQueryWrapper<TbCareNoInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TbCareNoInfo::getReason, reasonType.getValue());
        List<TbCareNoInfo> list = tbCareNoInfoMapper.selectList(queryWrapper);
        return list;
    }

    public static String getExceptionDetail(Exception e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        e.printStackTrace(pw);
        pw.flush();
        sw.flush();
        return sw.toString();
    }
}
